package erfgame.frontend.desktop.view.layer;

import java.awt.Component;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.JLayeredPane;

@SuppressWarnings("serial")
public class LayerView extends JLayeredPane {
	public LayerView( int offset, Component[] layers ) {
		for( int i=0; i<layers.length; i++ ) {
			this.add(layers[i], i+offset);
		}
		this.addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent e) {
				int width = getWidth();
				int height = getHeight();
				Component[] components = getComponents();
				for( int i=components.length; i>0; ) {
					i--;
					components[i].setSize(width, height);
				}
			}
		});
	}
}
